﻿using DevExpress.Mvvm;
using DevExpress.Mvvm.DataAnnotations;
using DevExpress.Mvvm.POCO;
using Microsoft.EntityFrameworkCore;
using orm.Migrations;
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;

namespace OneStress.ViewModels
{

    [POCOViewModel]
    public class DataManagerViewModel : PanelWorkspaceViewModel {
        public DataManagerViewModel() {

            DisplayName = "DataManager";
            Glyph = Images.SolutionExplorer;
            PropertiesWindow = Images.PropertiesWindow;
            ShowAllFiles = Images.ShowAllFiles;
            Refresh = Images.Refresh;
            
        }

        public OrgEntity CurrentOrg;

        public List<OrgEntity> Orgnizations
        {
            get
            {
                return OrgnizationManager.Instance.Orgnizations;
            }
        }

 
        public ImageSource PropertiesWindow { get; set; }
        public ImageSource Refresh { get; set; }
        public ImageSource ShowAllFiles { get; set; }
    
        protected override string WorkspaceName { get { return "LeftHost"; } }

    
       
        public void SelectOrg(OrgEntity org)
        {
            OrgnizationManager.Instance.CurrentOrg = org;
            //属性和数据使用了两个不同的ViewModel，要实现两者通信必须用Messenger
            Messenger.Default.Send(OrgnizationManager.Instance.CurrentOrg);
        }
    }
}
